package com.baoyi.pooke;

import net.youmi.android.AdManager;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

import com.baoyi.adapter.WeekItemAdapter;
import com.baoyi.content.content;
import com.baoyi.widget.WeekItemWidget;

public class YearListUI extends Activity {
	static {
		AdManager.init(content.id, content.pwd, content.time, content.con,
				content.banben);
	}
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.weeklist);
		listView = (ListView) findViewById(R.id.weeklist);
		WeekItemAdapter adapter = new WeekItemAdapter(this,"year");
		listView.setAdapter(adapter);
		listView.setDividerHeight(0);
		listView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				WeekItemWidget imageView = (WeekItemWidget) arg1;
				Intent item = new Intent(YearListUI.this, ImageViewUI.class);
				item.putExtra("id", imageView.getImageItem().getId());
				startActivity(item);
			}
		});
	}

	/**
	 * 重新回到页面后更新数据！
	 */
	@Override
	protected void onRestart() {
		super.onRestart();
		WeekItemAdapter adapter = new WeekItemAdapter(this,"year");
		listView.setAdapter(adapter);
	}
	private ListView listView;
}

